<?php
/*
* Creator DB instance
*/
class DB{
	
	/*
	* db instance
	*/
	private static $dbinstance;
	
	private function __construct(){}	

	/*
	* get single instance db
	*/
	public static function GetInstance(){
		if(!self::$dbinstance){
			$dsn = DB_PROVIDER.':host='.DB_HOST.';dbname='.DB_NAME;
			try{
			   self::$dbinstance = new PDO($dsn,DB_USER,DB_PASSWORD);
			   self::$dbinstance->query('SET NAMES utf8');	
			   self::$dbinstance->query('SET CHARACTER_SET utf8_unicode_ci');				 
			   				
			}catch(PDOException $e){
				die('Connection error: ' . $e->getMessage());
			}
			
		}			
		return self::$dbinstance;
	}
}
?>
